<template>
  <div class="editUser">
    <el-form ref="userForm" :model="userForm" class="user_form" auto-complete="on" :rules="userRules">
      <el-form-item prop="userName" label="用户姓名:">
        <el-input v-model="userForm.userName" placeholder="请输入用户姓名"></el-input>
      </el-form-item>

      <!-- <el-form-item prop="userPrice" label="用户价格">
        <el-input v-model="userForm.userPrice" placeholder="请输入价格"></el-input>
      </el-form-item> -->
      <el-form-item prop="userAccount" label="用户账号">
        <el-input v-model="userForm.userStore" placeholder="请输入用户账号"></el-input>
      </el-form-item>
      <el-form-item prop="userStatus" label="是否启用">
        <el-radio v-model="radio" label="1">是</el-radio>
        <el-radio v-model="radio" label="2">否</el-radio>
      </el-form-item>
      <el-form-item prop="userImg" label="用户图片">
        <el-upload action="#" list-type="picture-card" :auto-upload="false">
          <i slot="default" class="el-icon-plus"></i>
          <div slot="file" slot-scope="{ file }">
            <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
            <span class="el-upload-list__item-actions">
              <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                <i class="el-icon-zoom-in"></i>
              </span>
              <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleDownload(file)">
                <i class="el-icon-download"></i>
              </span>
              <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
                <i class="el-icon-delete"></i>
              </span>
            </span>
          </div>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="" />
        </el-dialog>
      </el-form-item>

      <!-- <el-form-item prop="userDescription" label="用户描述">
        <el-input type="textarea" v-model="userForm.userDescription" placeholder="请输入库存"></el-input>
      </el-form-item> -->


    </el-form>
    <div class="myButton">
      <el-button type="warning" round @click="goback()">返回</el-button>
    <el-button type="warning" round>保存</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      radio: '1',
      dialogImageUrl: '',
      dialogVisible: false,
      disabled: false,
      userForm: {},
      userRules: {
        userName: [
          { required: true, message: "名称不能为空", trigger: "blur" },
        ],
        userAccount: [
          { required: true, message: "账号不能为空", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleDownload(file) {
      console.log(file);
    },
    goback(){
      this.$router.go(-1)
    }
  },
};
</script>

<style lang="scss">
.editUser {
  // .main{
  //   width: 80%;
  //   margin: auto;
  //   border: 1px solid black;
  // }
  // border: 1px solid black;
  width: 90%;
  margin: auto;
  margin-top: 30px;

  .el-form-item {
    // 重置或调整 el-form-item 的样式
    margin-bottom: 20px; // 根据需要调整

    // 调整 label 的宽度
    .el-form-item__label {
      width: 100px; // 根据您的需要调整
      text-align: right; // 使标签右对齐
    }

    // 调整 content 的 margin 以与 label 对齐
    .el-form-item__content {
      margin-left: 120px; // 通常等于 label 的宽度加上一些间距
    }
  }

  .user_form {
    .el-input__inner {
      // margin-left: 50px;
      width: 70%;
    }
  }
  .myButton{
    margin-left: 500px;
  }
}
</style>
